//
//  DHS2_BaseViewController.m
//  Dresshere
//
//  Created by ZhangPeng on 2018/6/7.
//  Copyright © 2018年 张朋. All rights reserved.
//

#import "DHS2_BaseViewController.h"

@interface DHS2_BaseViewController ()

@end

@implementation DHS2_BaseViewController

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    NSLog(@"当前显示页面：%@",NSStringFromClass([self class]));
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    if (!self.navView) {
        CGFloat top = 0;
        if (iPhoneX) {
            top = 20;
        }
        self.navView = [[UIView alloc] initWithFrame:CGRectMake(0, top, kScreenWidth, 64)];
        self.navView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:self.navView];
    }
    if (!self.backButton) {
        self.backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, self.navView.height - 44, 44, 44)];
        [self.backButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        [self.backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
        [self.navView addSubview:self.backButton];
    }
    if (!self.titleLabel) {
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(44, self.navView.height - 44, kScreenWidth - 88, 44)];
        self.titleLabel.font = [UIFont systemFontOfSize:18];
        self.titleLabel.textColor = [UIColor blackColor];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.navView addSubview:self.titleLabel];
    }
    
    CGFloat lineSpace = 0;
    if (iPhoneX) {
        lineSpace = 3;
    }
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, self.navView.height + lineSpace, kScreenWidth, 1)];
    lineView.backgroundColor = RGBAlpha(0, 0, 0, 0.1);
    [self.navView addSubview:lineView];
    
    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
}

- (void)backAction{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    [[SDWebImageManager sharedManager].imageCache clearMemory];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
